<!-- 岗位 首页 -->
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!-- 搜索栏-->
      <div v-if="crud.props.searchToggle">
        <el-row :gutter="10">
          <el-col :xs="24" :sm="8" :md="7" :lg="6">
            <dep-tree :dep-input-change="depSearchInput" :load-on-mounted="true" />
          </el-col>
          <el-col :xs="24" :sm="16" :md="17" :lg="18">
            <el-input v-model="query.name" clearable size="small" placeholder="输入岗位名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
            <rrOperation />
          </el-col>
        </el-row>

      </div>
      <!-- 按钮-->
      <crud-opts :permission="permission" />
    </div>
    <!-- 表格-->
    <!-- 如果需要指定表格高度，可以在el-table 中style 属性后 加入属性 height="70vh"-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      border
      style="width: 100% "
      row-key="id"
      stripe
      tooltip-effect="dark"
      :highlight-current-row="true"
      @sort-change="crud.sortChange"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="selection" width="39" />
      <!--<el-table-column type="index" width="45" />-->
      <el-table-column prop="name" label="岗位名称" sortable="custom" />

      <el-table-column prop="code" label="岗位编码" sortable="custom" />

      <el-table-column prop="topid" label="限定组织的顶级id" sortable="custom" :show-overflow-tooltip="true" />

      <!-- <el-table-column prop="depId" label="组织id" /> -->
      <el-table-column prop="depName" label="所属组织" />
      <el-table-column prop="paixu" label="排序" width="80" header-align="center" align="center" sortable="custom" :show-overflow-tooltip="true" />
      <el-table-column
        prop="status"
        label="状态"
        width="80"
        sortable="custom"
      >
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.status"
            class="switch"
            :width="50"
            :active-value="1"
            :inactive-value="0"
            active-color="#13ce66"
            inactive-color="#ff4949"
            active-text="启用"
            inactive-text="禁用"
            :disabled="!permission.has('edit')"
            @change="crud.changeStatusWithNum(scope.row, scope.row.status, {'title':'id','column':'id'})"
          />
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" :show-overflow-tooltip="true" header-align="center" sortable="custom" />
      <el-table-column fixed="right" label="操作" width="120" header-align="center" align="center">
        <template slot-scope="scope">
          <!-- 操作按钮，简介操作的（不需要详情和扩展的），可以只引用 udOperation -->
          <udOperation
            :data="scope.row"
            :permission="permission"
          />
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页插件, 如果不需要注释掉下面一行,以及引入的 pagination 组件即可 -->
    <pagination />
    <!-- 表单 -->
    <SysStationForm />
    <!-- 详情, 如果用不到，注释下面一行 -->
    <SysStationInfo />
  </div>
</template>
<!-- 岗位 首页 -->
<script>
import crudApi, { page } from '@/api/sys/Station'
import SysStationForm from './form'
import SysStationInfo from './info'
import CRUD, { presenter, header } from '@crud/crud'
import CrudOpts from '@crud/CRUD.operation'
import rrOperation from '@crud/RR.operation'
// import udOperation from '@crud/UD.operation'
import udOperation from '@crud/RUD.operation'
import pagination from '@crud/Pagination'
import DepTree from '@/views/components/depTree'
export default {
  name: 'SysStation',
  dicts: [
    'common_status'
  ], // 字典
  components: {
    CrudOpts,
    rrOperation,
    udOperation,
    pagination,
    SysStationInfo,
    DepTree,
    SysStationForm
  },
  cruds() {
    return CRUD({ title: '岗位', initDataMethod: page, crudMethod: { ...crudApi }})
  },
  mixins: [presenter(), header()],
  data() {
    return {
      permission: new Map()
    }
  },
  mounted() {
    this.permission = this.$store.state.menu.buttonPermission.get('SysStation')
  },
  methods: {
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    depSearchInput(depId) {
      this.query.depId = depId
    }
  }
}
</script>

<style scoped>

</style>
